<!--
 @description 立面单个问题项
 @fileName FileItem.vue
 @author zengqiongying
 @created 2023/06/15 14:58:02
-->
<template>
  <Card>
    <div class="facade-file-item">
      <div class="title">
        <span class="name">{{ detail.facadeName }} - {{ detail.sortNumber }}.</span>
        <div class="btns" v-if="!readonly">
          <div class="btn edit" @click.stop="onEdit"></div>
          <div class="btn del" @click.stop="onDelete"></div>
        </div>
      </div>
      <div class="title">
        <span class="tip nature">{{ detail.projectNature }}</span>
        <span class="tip poperty"> {{ detail.problemProperty }}</span>
        <span class="tip poperty"> {{ detail.problemPropertyPattern }}</span>
      </div>
      <div class="content">{{ detail.imgCustomName }}</div>
      <div class="img-list">
        <div class="check-image-item">
          <div class="img-container">
            <CheckImage :modelValue="detail.sysFileUrl" readonly />
          </div>
          <div class="name">整改前</div>
        </div>
        <div class="check-image-item">
          <div class="img-container">
            <CheckImage :modelValue="detail.afterSysFileUrl" readonly />
          </div>
          <div class="name">已整改</div>
        </div>
      </div>
    </div>
  </Card>
</template>

<script>
  import { defineComponent, reactive } from 'vue'
  import CheckImage from '@/views/components/CheckImage/index.vue'
  import Card from '@/components/Card/index'
  export default defineComponent({
    name: 'FFileItem',
    components: { Card, CheckImage },
    props: {
      facadeName: {
        // 立面名称
        type: String,
        default: ''
      },
      detail: {
        // 里面问题数据
        type: Object,
        default: () => {}
      },
      readonly: {
        // 是否只读
        type: Boolean,
        default: false
      }
    },
    emits: ['delete', 'edit'],
    setup(props, { emit }) {
      const onDelete = () => {
        emit('delete')
      }
      const onEdit = () => {
        emit('edit')
      }
      return {
        onDelete,
        onEdit
      }
    }
  })
</script>
<style lang="less" scoped>
  .facade-file-item {
    padding: 0 16px;
    .title {
      margin-bottom: 10px;
      display: flex;
      align-items: center;
      .name {
        font: var(--font-main-title-strengthen);
        color: var(--texticon-default-strong);
        margin-right: 4px;
      }
      .tip {
        margin-right: 4px;
        padding: 2px 4px;
        border-radius: var(--radius-l);
        font: var(--font-point);
      }
      .nature {
        background: var(--bg-focusing-brand);
        color: var(--texticon-color-brand-normal);
      }
      .poperty {
        background: var(--bg-focusing-warning);
        color: var(--texticon-color-secondary-normal);
      }
      .btns {
        flex: 1;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        .btn {
          width: 24px;
          height: 24px;
          margin-left: 16px;
          background-size: 24px 24px;
          background-repeat: no-repeat;
          &.edit {
            background-image: url(~@/assets/images/icon-edit-green.png);
          }
          &.del {
            background-image: url(~@/assets/images/icon-del-red.png);
          }
        }
      }
    }
    .content {
      font: var(--font-main-body);
      color: var(--texticon-default-stronger);
    }
    .img-list {
      margin-top: 8px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
  }

  .check-image-item {
    .img-container {
      position: relative;
      width: 161px;
      height: 110px;
    }
    .name {
      margin-top: 8px;
      font: var(--font-main-body);
      color: var(--texticon-default-normal);
      text-align: center;
    }
  }
</style>
